<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: MobilityBase Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00145.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="#pro-static-attribs">Static Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">MobilityBase Class Reference<div class="ingroups"><a class="el" href="a00513.html">mobility - modules handling the mobility of the hosts</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="MobilityBase" --><!-- doxytag: inherits="BasicModule,IMobility" -->
<p>Abstract base class for mobility modules.  
 <a href="a00145.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00363_source.html">MobilityBase.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for MobilityBase:</div>
<div class="dyncontent">
<div class="center"><img src="a00878.png" border="0" usemap="#MobilityBase_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for MobilityBase:</div>
<div class="dyncontent">
<div class="center"><img src="a00879.png" border="0" usemap="#MobilityBase_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00880.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18">BorderPolicy</a> { <a class="el" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18add05fd1c0ea65bba1c8e25fe7742acca">REFLECT</a>, 
<a class="el" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18a4dd7d01ab62c958cb7b3cb27f78a490a">WRAP</a>, 
<a class="el" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18a7fe0cd1ed529388e665b7e898596c236">PLACERANDOMLY</a>, 
<a class="el" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18a0e070e3cd7ad937cb82bc15dbe81e918">RAISEERROR</a>
 }</td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac86018a375bf83f14dc36bf222bfd5bd"></a><!-- doxytag: member="MobilityBase::numInitStages" ref="ac86018a375bf83f14dc36bf222bfd5bd" args="() const " -->
virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#ac86018a375bf83f14dc36bf222bfd5bd">numInitStages</a> () const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the required number of initialize stages. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4c79fdde6758f5cb3b879d8a712911c9"></a><!-- doxytag: member="MobilityBase::initialize" ref="a4c79fdde6758f5cb3b879d8a712911c9" args="(int stage)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a4c79fdde6758f5cb3b879d8a712911c9">initialize</a> (int stage)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes mobility model parameters in 4 stages. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae4fcd350112d303b0d58f39e56b07c6b"></a><!-- doxytag: member="MobilityBase::initializePosition" ref="ae4fcd350112d303b0d58f39e56b07c6b" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#ae4fcd350112d303b0d58f39e56b07c6b">initializePosition</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the position from the display string or from module parameters. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8088f9febe7400b52438d17a53dceb72"></a><!-- doxytag: member="MobilityBase::handleMessage" ref="a8088f9febe7400b52438d17a53dceb72" args="(cMessage *msg)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a8088f9febe7400b52438d17a53dceb72">handleMessage</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">This modules should only receive self-messages. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a42e16e37a9670e4faa781e30540094cb"></a><!-- doxytag: member="MobilityBase::handleSelfMessage" ref="a42e16e37a9670e4faa781e30540094cb" args="(cMessage *msg)=0" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a42e16e37a9670e4faa781e30540094cb">handleSelfMessage</a> (cMessage *msg)=0</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Called upon arrival of a self messages, subclasses must override. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acf7fd78c52300a9e1738e91282df3f45"></a><!-- doxytag: member="MobilityBase::updateVisualRepresentation" ref="acf7fd78c52300a9e1738e91282df3f45" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#acf7fd78c52300a9e1738e91282df3f45">updateVisualRepresentation</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Moves the visual representation module's icon to the new position on the screen. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad8425adf03e698223618ddfcaaadef14"></a><!-- doxytag: member="MobilityBase::emitMobilityStateChangedSignal" ref="ad8425adf03e698223618ddfcaaadef14" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#ad8425adf03e698223618ddfcaaadef14">emitMobilityStateChangedSignal</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Emits a signal with the updated mobility state. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a07eac3b0d197edaa3e9509e80ae21af1"></a><!-- doxytag: member="MobilityBase::getRandomPosition" ref="a07eac3b0d197edaa3e9509e80ae21af1" args="()" -->
virtual <a class="el" href="a00065.html">Coord</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a07eac3b0d197edaa3e9509e80ae21af1">getRandomPosition</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a new random position satisfying the constraint area. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a39ea0e8ddefc5b5b30ae969f3a2d8b43"></a><!-- doxytag: member="MobilityBase::findVisualRepresentation" ref="a39ea0e8ddefc5b5b30ae969f3a2d8b43" args="()" -->
virtual cModule *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a39ea0e8ddefc5b5b30ae969f3a2d8b43">findVisualRepresentation</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the module that represents the object moved by this mobility module. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a70e7b8c7610a007a4b40c769d7599f70"></a><!-- doxytag: member="MobilityBase::isOutside" ref="a70e7b8c7610a007a4b40c769d7599f70" args="()" -->
virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a70e7b8c7610a007a4b40c769d7599f70">isOutside</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if the mobility is outside of the constraint area. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#ad987f8c910a37c23f29b1800044c9851">reflectIfOutside</a> (<a class="el" href="a00065.html">Coord</a> &amp;targetPosition, <a class="el" href="a00065.html">Coord</a> &amp;speed, double &amp;angle)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility function to reflect the node if it goes outside the constraint area.  <a href="#ad987f8c910a37c23f29b1800044c9851"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a7d1173c29234a0c8fb120fd3c6471901">wrapIfOutside</a> (<a class="el" href="a00065.html">Coord</a> &amp;targetPosition)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility function to wrap the node to the opposite edge (torus) if it goes outside the constraint area.  <a href="#a7d1173c29234a0c8fb120fd3c6471901"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a1591745daa837f50c64ef1e485f05ea2">placeRandomlyIfOutside</a> (<a class="el" href="a00065.html">Coord</a> &amp;targetPosition)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility function to place the node randomly if it goes outside the constraint area.  <a href="#a1591745daa837f50c64ef1e485f05ea2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae3fb0f9bd82fb86a59d34da6c8c42582"></a><!-- doxytag: member="MobilityBase::raiseErrorIfOutside" ref="ae3fb0f9bd82fb86a59d34da6c8c42582" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#ae3fb0f9bd82fb86a59d34da6c8c42582">raiseErrorIfOutside</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility function to raise an error if the node gets outside the constraint area. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2583560e5b7b4dcc26b93eadfe17056e"></a><!-- doxytag: member="MobilityBase::handleIfOutside" ref="a2583560e5b7b4dcc26b93eadfe17056e" args="(BorderPolicy policy, Coord &amp;targetPosition, Coord &amp;speed, double &amp;angle)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a2583560e5b7b4dcc26b93eadfe17056e">handleIfOutside</a> (<a class="el" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18">BorderPolicy</a> policy, <a class="el" href="a00065.html">Coord</a> &amp;targetPosition, <a class="el" href="a00065.html">Coord</a> &amp;speed, double &amp;angle)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Invokes one of <a class="el" href="a00145.html#ad987f8c910a37c23f29b1800044c9851" title="Utility function to reflect the node if it goes outside the constraint area.">reflectIfOutside()</a>, <a class="el" href="a00145.html#a7d1173c29234a0c8fb120fd3c6471901" title="Utility function to wrap the node to the opposite edge (torus) if it goes outside the constraint area...">wrapIfOutside()</a> and <a class="el" href="a00145.html#a1591745daa837f50c64ef1e485f05ea2" title="Utility function to place the node randomly if it goes outside the constraint area.">placeRandomlyIfOutside()</a>, depending on the given border policy. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3df52e779977d443eae7e5edee8fc7b9"></a><!-- doxytag: member="MobilityBase::visualRepresentation" ref="a3df52e779977d443eae7e5edee8fc7b9" args="" -->
cModule *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a3df52e779977d443eae7e5edee8fc7b9">visualRepresentation</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to visual representation module, to speed up repeated access. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5b75464ca5724b99186e8577f8345ed8"></a><!-- doxytag: member="MobilityBase::constraintAreaMin" ref="a5b75464ca5724b99186e8577f8345ed8" args="" -->
<a class="el" href="a00065.html">Coord</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8">constraintAreaMin</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">3 dimensional position and size of the constraint area (in meters). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a321a70920d0e44b3deaf5c161331da18"></a><!-- doxytag: member="MobilityBase::constraintAreaMax" ref="a321a70920d0e44b3deaf5c161331da18" args="" -->
<a class="el" href="a00065.html">Coord</a>&#160;</td><td class="memItemRight" valign="bottom"><b>constraintAreaMax</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a82ae637969433a492154b26039b84038"></a><!-- doxytag: member="MobilityBase::lastPosition" ref="a82ae637969433a492154b26039b84038" args="" -->
<a class="el" href="a00065.html">Coord</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a82ae637969433a492154b26039b84038">lastPosition</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The last position that was reported. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-static-attribs"></a>
Static Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a10491208fc1f207870d49401de1ae52c"></a><!-- doxytag: member="MobilityBase::mobilityStateChangedSignal" ref="a10491208fc1f207870d49401de1ae52c" args="" -->
static simsignal_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00145.html#a10491208fc1f207870d49401de1ae52c">mobilityStateChangedSignal</a> = SIMSIGNAL_NULL</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">A signal used to publish mobility state changes. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Abstract base class for mobility modules. </p>
<p>Mobility modules inheriting from this base class may be stationary or may change their mobility state over simulation time. This base class only provides a few utility methods to handle some common tasks among mobility modules.</p>
<p>Subclasses must redefine <a class="el" href="a00145.html#a42e16e37a9670e4faa781e30540094cb" title="Called upon arrival of a self messages, subclasses must override.">handleSelfMessage()</a> to update the mobility state and schedule the next update. Subclasses must also redefine <a class="el" href="a00145.html#a4c79fdde6758f5cb3b879d8a712911c9" title="Initializes mobility model parameters in 4 stages.">initialize()</a> to read their specific parameters and schedule the first update.</p>
<p>This base class also provides random initial placement as a default mechanism. After initialization the module updates the display and emits a signal to subscribers providing the mobility state. Receivers of this signal can query the mobility state through the <a class="el" href="a00101.html" title="Abstract base class defining the public interface that must be provided by all mobility modules...">IMobility</a> interface.</p>
<dl class="author"><dt><b>Author:</b></dt><dd>Daniel Willkomm, Andras Varga </dd></dl>
</div><hr/><h2>Member Enumeration Documentation</h2>
<a class="anchor" id="aa67dcad3ed1e7fe0164b84131aea2b18"></a><!-- doxytag: member="MobilityBase::BorderPolicy" ref="aa67dcad3ed1e7fe0164b84131aea2b18" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18">MobilityBase::BorderPolicy</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Selects how a mobility module should behave if it reaches the edge of the constraint area. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00145.html#a2583560e5b7b4dcc26b93eadfe17056e" title="Invokes one of reflectIfOutside(), wrapIfOutside() and placeRandomlyIfOutside(), depending on the giv...">handleIfOutside()</a> </dd></dl>
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="aa67dcad3ed1e7fe0164b84131aea2b18add05fd1c0ea65bba1c8e25fe7742acca"></a><!-- doxytag: member="REFLECT" ref="aa67dcad3ed1e7fe0164b84131aea2b18add05fd1c0ea65bba1c8e25fe7742acca" args="" -->REFLECT</em>&nbsp;</td><td>
<p>reflect off the wall </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="aa67dcad3ed1e7fe0164b84131aea2b18a4dd7d01ab62c958cb7b3cb27f78a490a"></a><!-- doxytag: member="WRAP" ref="aa67dcad3ed1e7fe0164b84131aea2b18a4dd7d01ab62c958cb7b3cb27f78a490a" args="" -->WRAP</em>&nbsp;</td><td>
<p>reappear at the opposite edge (torus) </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="aa67dcad3ed1e7fe0164b84131aea2b18a7fe0cd1ed529388e665b7e898596c236"></a><!-- doxytag: member="PLACERANDOMLY" ref="aa67dcad3ed1e7fe0164b84131aea2b18a7fe0cd1ed529388e665b7e898596c236" args="" -->PLACERANDOMLY</em>&nbsp;</td><td>
<p>placed at a randomly chosen position within the constraint area </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="aa67dcad3ed1e7fe0164b84131aea2b18a0e070e3cd7ad937cb82bc15dbe81e918"></a><!-- doxytag: member="RAISEERROR" ref="aa67dcad3ed1e7fe0164b84131aea2b18a0e070e3cd7ad937cb82bc15dbe81e918" args="" -->RAISEERROR</em>&nbsp;</td><td>
<p>stop the simulation with error </p>
</td></tr>
</table>
</dd>
</dl>
<div class="fragment"><pre class="fragment">                      {
        <a class="code" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18add05fd1c0ea65bba1c8e25fe7742acca" title="reflect off the wall">REFLECT</a>,       
        <a class="code" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18a4dd7d01ab62c958cb7b3cb27f78a490a" title="reappear at the opposite edge (torus)">WRAP</a>,          
        <a class="code" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18a7fe0cd1ed529388e665b7e898596c236" title="placed at a randomly chosen position within the constraint area">PLACERANDOMLY</a>, 
        <a class="code" href="a00145.html#aa67dcad3ed1e7fe0164b84131aea2b18a0e070e3cd7ad937cb82bc15dbe81e918" title="stop the simulation with error">RAISEERROR</a>     
    };
</pre></div>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a1591745daa837f50c64ef1e485f05ea2"></a><!-- doxytag: member="MobilityBase::placeRandomlyIfOutside" ref="a1591745daa837f50c64ef1e485f05ea2" args="(Coord &amp;targetPosition)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MobilityBase::placeRandomlyIfOutside </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00065.html">Coord</a> &amp;&#160;</td>
          <td class="paramname"><em>targetPosition</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Utility function to place the node randomly if it goes outside the constraint area. </p>
<p>Decision is made on lastPosition, but targetPosition will also be updated. (Pass a dummy you don't have it). </p>

<p>References <a class="el" href="a00145.html#a07eac3b0d197edaa3e9509e80ae21af1">getRandomPosition()</a>, <a class="el" href="a00145.html#a70e7b8c7610a007a4b40c769d7599f70">isOutside()</a>, and <a class="el" href="a00145.html#a82ae637969433a492154b26039b84038">lastPosition</a>.</p>

<p>Referenced by <a class="el" href="a00145.html#a2583560e5b7b4dcc26b93eadfe17056e">handleIfOutside()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordflow">if</span> (<a class="code" href="a00145.html#a70e7b8c7610a007a4b40c769d7599f70" title="Returns true if the mobility is outside of the constraint area.">isOutside</a>())
    {
        <a class="code" href="a00065.html" title="Class for storing 3D coordinates.">Coord</a> newPosition = <a class="code" href="a00145.html#a07eac3b0d197edaa3e9509e80ae21af1" title="Returns a new random position satisfying the constraint area.">getRandomPosition</a>();
        targetPosition += newPosition - <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>;
        lastPosition = newPosition;
    }
}
</pre></div>
</div>
</div>
<a class="anchor" id="ad987f8c910a37c23f29b1800044c9851"></a><!-- doxytag: member="MobilityBase::reflectIfOutside" ref="ad987f8c910a37c23f29b1800044c9851" args="(Coord &amp;targetPosition, Coord &amp;speed, double &amp;angle)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MobilityBase::reflectIfOutside </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00065.html">Coord</a> &amp;&#160;</td>
          <td class="paramname"><em>targetPosition</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00065.html">Coord</a> &amp;&#160;</td>
          <td class="paramname"><em>speed</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double &amp;&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Utility function to reflect the node if it goes outside the constraint area. </p>
<p>Decision is made on pos, but the variables passed as args will also be updated. (Pass dummies you don't have some of them). </p>

<p>References <a class="el" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8">constraintAreaMin</a>, and <a class="el" href="a00145.html#a82ae637969433a492154b26039b84038">lastPosition</a>.</p>

<p>Referenced by <a class="el" href="a00145.html#a2583560e5b7b4dcc26b93eadfe17056e">handleIfOutside()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordtype">int</span> sign;
    <span class="keywordtype">double</span> dummy;
    <span class="keywordflow">if</span> (<a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.x &lt; <a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.x || constraintAreaMax.x &lt; <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.x) {
        sign = reflect(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.x, constraintAreaMax.x, <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.x, speed.x);
        reflect(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.x, constraintAreaMax.x, targetPosition.x, dummy);
        angle = 90 + sign * (angle - 90);
    }
    <span class="keywordflow">if</span> (<a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.y &lt; <a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.y || constraintAreaMax.y &lt; <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.y) {
        sign = reflect(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.y, constraintAreaMax.y, <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.y, speed.y);
        reflect(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.y, constraintAreaMax.y, targetPosition.y, dummy);
        angle = sign * angle;
    }
    <span class="keywordflow">if</span> (<a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.z &lt; <a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.z || constraintAreaMax.z &lt; <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.z) {
        sign = reflect(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.z, constraintAreaMax.z, <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.z, speed.z);
        reflect(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.z, constraintAreaMax.z, targetPosition.z, dummy);
        <span class="comment">// NOTE: angle is not affected</span>
    }
}
</pre></div>
</div>
</div>
<a class="anchor" id="a7d1173c29234a0c8fb120fd3c6471901"></a><!-- doxytag: member="MobilityBase::wrapIfOutside" ref="a7d1173c29234a0c8fb120fd3c6471901" args="(Coord &amp;targetPosition)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MobilityBase::wrapIfOutside </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00065.html">Coord</a> &amp;&#160;</td>
          <td class="paramname"><em>targetPosition</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Utility function to wrap the node to the opposite edge (torus) if it goes outside the constraint area. </p>
<p>Decision is made on pos, but targetPosition will also be updated. (Pass a dummy you don't have it). </p>

<p>References <a class="el" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8">constraintAreaMin</a>, and <a class="el" href="a00145.html#a82ae637969433a492154b26039b84038">lastPosition</a>.</p>

<p>Referenced by <a class="el" href="a00145.html#a2583560e5b7b4dcc26b93eadfe17056e">handleIfOutside()</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordflow">if</span> (<a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.x &lt; <a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.x || constraintAreaMax.x &lt; <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.x) {
        wrap(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.x, constraintAreaMax.x, <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.x);
        wrap(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.x, constraintAreaMax.x, targetPosition.x);
    }
    <span class="keywordflow">if</span> (<a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.y &lt; <a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.y || constraintAreaMax.y &lt; <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.y) {
        wrap(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.y, constraintAreaMax.y, <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.y);
        wrap(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.y, constraintAreaMax.y, targetPosition.y);
    }
    <span class="keywordflow">if</span> (<a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.z &lt; <a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.z || constraintAreaMax.z &lt; <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.z) {
        wrap(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.z, constraintAreaMax.z, <a class="code" href="a00145.html#a82ae637969433a492154b26039b84038" title="The last position that was reported.">lastPosition</a>.z);
        wrap(<a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.z, constraintAreaMax.z, targetPosition.z);
    }
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/mobility/models/<a class="el" href="a00363_source.html">MobilityBase.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/mobility/models/MobilityBase.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00145.html">MobilityBase</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
